// Functions.js
// Various javascript functions uses throughout the site

// getComments(photoid) : Gets the comments associated with a particular file
function getComments(photo_url) {

	var commentbox = document.getElementById("comments");

	commentbox.className = "commentsover";

	// Loading message
	commentbox.innerHTML = "<p>Getting comments...</p>";

	// Get the comments
	url = '/media/comments/url/' + photo_url;
	xmlhttp.open("GET", url ,true);
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			commentbox.innerHTML = xmlhttp.responseText;
		}
	}

	xmlhttp.send(null)
}

function editTitle(id) {
	document.getElementById('title_text_' + id).style.display = 'none';
	document.getElementById('title_editable_' + id).style.display = 'inline';
	document.getElementById('submit_area_' + id).style.display = 'inline';
}

function showTitle(id) {
	document.getElementById('title_text_' + id).style.display = 'inline';
	document.getElementById('title_editable_' + id).style.display = 'none';
	document.getElementById('submit_area_' + id).style.display = 'none';
}

function deleteMedia(id) {
	sure = confirm('Are you sure you want to delete this?');

	if (sure) {
		document.getElementById('delform_' + id).submit();
	}
}
